import { ACCESS_TOKEN, REFRESH_TOKEN } from "@/constants";
import axios from "axios";
import React, { useState } from "react";
import { Button } from "./button";

export const AuthModal = ({
    setShowAuth,
    setShowUserProfile
}: {
    setShowAuth: (show: boolean) => void;
    setShowUserProfile: (show: boolean) => void;
}) => {
    // Form states defined
    const [loginForm, setLoginForm] = useState<{ 
        email: string; 
        password: string 
    }>({ 
        email: "", 
        password: "" 
    });
    
    const [registerForm, setRegisterForm] = useState<{
        username: string;
        email: string;
        password: string;
        password2: string;
    }>({
        username: "",
        email: "",
        password: "",
        password2: ""
    });

    const [registerView, setRegisterView] = useState<boolean>(false)
    const [loggingIn, setLoggingIn] = useState<boolean>(false)
    const [creatingUser, setCreatingUser] = useState<boolean>(false)

    // Authentication functions
    const handleLogin = async () => {
        try {
            setLoggingIn(true)
            const res = await axios.post(`${process.env.NEXT_PUBLIC_BACKEND_URL}/auth/login/`, {
                email: loginForm.email,
                password: loginForm.password
            })
            if (res.data.access) {
                
            } 
        }
    }

}